import request from '@/config/axios'


//获取左侧树状列表
export const getList = async (divisionCode) => {
    return await request.get({ url: `baseDic/dic-manager/listAll?divisionCode=${divisionCode}`})
}

export const getPageList = async (pageList: { typeId: any; pageSize: string; pageNo: string }) => {
    return await request.post({ url: 'baseDic/pageList', data: pageList })
}

//获取数据文件列表
export const getDataPage = async (treeId: bigint,libraryTypes: string) => {
    return await request.get({ url: 'data/file/page?treeId='+treeId+"&libraryTypes="+libraryTypes})
}
//批量删除数据文件
export const delDataFile = async (ids: string,libraryTypes: string,treeId: string,cName: string,parentId: string) => {
    return await request.get({ url: '/data/file/delete?ids=' + ids+"&libraryTypes="+libraryTypes+"&treeId="+treeId+"&cName="+cName+"&parentId="+parentId})
}
//批量删除表数据
export const delPublicData = async (ids: string,DBTableName: string,libraryTypes: string,treeId: bigint) => {
    return await request.get({ url: '/data/file/delPublic?ids=' + ids+"&DBTableName="+DBTableName+"&libraryTypes="+libraryTypes+"&treeId="+treeId})
}

// 上传文件
export const confirm = async (formData) => {
    return await request.post({
        url: 'baseDic/upload',
        data: formData,
        headersType:"multipart/form-data",
    });
}

// 分片上传校验
export const verifyFile = (data) => {
    return request.post({ url: '/baseDic/verifyFile', data: data })
}

// 上传分片
export const uploadChunk = (data) => {
    return request.upload({ url: '/baseDic/uploadChunk', data: data })
}

// 合并分片 保存
export const merge = (data) => {
    return request.post({ url: '/baseDic/merge', data: data })
}

//使用设置   原始/baseDic/dic-manager/setList
export const getSetList = async() => {
    return await request.get({ url: 'baseDic/dic-manager/listAll'})
}
// 获取使用设置(新，区分各省用户)
export const getUseSetList = async() => {
  return await request.get({ url: 'baseDic/dic-manager/listUsingConfig'})
}

// export const getInsertUsing = async(id:bigint,name: string,libType: bigint,dataType:string) =>{
//     return await request.get({ url: '/baseDic/dic-manager/insertUsing?id='+id+"&name="+name+"&libType="+libType+"&dataType="+dataType})
// }
//  保存使用设置
export const analysisSaveUseset = (data) => {
    return request.post({ url: '/baseDic/dic-manager/saveUseSetConfig', data: data })
}

// 左侧城市下拉菜单
export const cityList = async () => {
    return await request.get({
        url: 'baseDic/provincelist',
    });
}
//数据文件下载
export const getZipDow = async (zipName: string,libraryTypes: string,cName: string,parentId: string,dataScope: string) => {
    return await request.get({
        url: '/data/file/zipDow?zipName='+zipName+"&libraryTypes="+libraryTypes+"&cName="+cName+"&parentId="+parentId+"&dataScope="+dataScope,
        responseType: 'blob'
    })
}
export const getShpDow = async (dataType,libraryTypes,dbTableName,name,minx,miny,xmax,ymax,parentId) => {
    return await request.get({
        url: '/data/file/dowShp?dataType='+dataType+"&libraryTypes="+libraryTypes+"&dbTableName="+dbTableName+"&name="+name+"&minx="+minx+"&miny="+miny+"&xmax="+xmax+"&ymax="+ymax+"&parentId="+parentId,
        responseType: 'blob'
    })
}
export const proList = async (longitude,latitude) => {
  return await request.get({
    url: '/data/file/proList?longitude='+longitude+"&latitude="+latitude,
  });
}

export const newProList = async () => {
  return await request.get({
    url: '/data/file/newProList'});
}

export const neiDowShp = async (longitude,latitude,dbName,dataType,shpName,parentId,libraryTypes) => {
  return await request.get({
    url: '/data/file/neiDowShp?longitude='+longitude+"&latitude="+latitude+"&dbName="+dbName+"&dataType="+dataType+"&shpName="+shpName+"&parentId="+parentId+"&libraryTypes="+libraryTypes,
    responseType: 'blob'
  });
}

// 获取数据范围
export const getlistAllData = async () => {
    return await request.get({ url: '/division/manager/listAll' })
}


// 字段对应关系
export const analysisShpFile = (data) => {
    return request.post({ url: '/baseDic/analysisShpFile', data: data })
}

// 图片上传
export const uploadImage = (file) => {
    return request.upload({ url: '/baseDic/imgUpload', data: file })
}
// 获取图片
export const getimgsList = (imgName) => {
    return request.get({ url: `baseDic/getImgInfo?imageName=${imgName}`, responseType: 'blob'  })
}
// 字段列表
export const getdescribeList = (describes) => {
    return request.get({ url: `/baseDic/getTableDescribe?treeId=${describes.treeId}&provinceCode=${describes.provinceCode}` })
}

// 下载模板
export const downTemplate = async (treeId: bigint) => {
    return await request.download({
      url: '/baseDic/dic-manager/downloadTemplate?typeId='+treeId,
      responseType: 'blob'
    });
  }